﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;

namespace Radar.Navigation
{
    internal class WaypointUniqueCollection
        : IEnumerable<Waypoint>
    {

        private List<Waypoint> _waypoints;

        public WaypointUniqueCollection()
        {
            _waypoints = new List<Waypoint>();
        }

        public Waypoint GetWaypointFor(Point point)
        {
            foreach (Waypoint w in _waypoints)
            {
                if (w.Point == point)
                {
                    return w;
                }
            }
            Waypoint newWayPoint = new Waypoint(point);
            _waypoints.Add(newWayPoint);
            return newWayPoint;
        }


        #region IEnumerable<Waypoint> Members

        public IEnumerator<Waypoint> GetEnumerator()
        {
            return _waypoints.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return _waypoints.GetEnumerator();
        }

        #endregion
    }
}
